Skip to content

feat: [SDK-5858] add OneSignal to iOS builds as a Swift package (1/2) - #920

Open
fadi-george wants to merge 1 commit into
v6from
fadi/sdk-5858
Open

fadi-george wants to merge 1 commit into
v6from
fadi/sdk-5858

Conversation

@fadi-george

@fadi-george fadi-george commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Description

One Line Summary

Add the OneSignal iOS SDK to exported Xcode projects as a Swift package instead of installing it through CocoaPods, and require Unity 6 for v6.

Details

Motivation

The CocoaPods trunk is read-only from Dec 2, 2026, so new OneSignalXCFramework versions can't be published there. Unity 6's PBXProject has Swift package APIs (AddRemotePackageReferenceAtVersion, AddRemotePackageFrameworkToProject). We chose these over bundling the XCFrameworks, which would add about 59 MB to the package and a copy step to every release. This is a breaking change, so it ships with v6.

Scope

  • New public OneSignalSwiftPackage.AddProduct(project, targetGuid, product) (iOS editor). It adds the OneSignal-XCFramework package reference pinned to Version and links a product to a target. It's idempotent on Append builds and when called from several post-processors, because Unity's APIs don't deduplicate. It re-pins an older version.
  • BuildPostProcessor:
    • The Podfile edits are removed.
    • The app and UnityFramework targets link OneSignalFramework and OneSignalInAppMessages, plus OneSignalLocation unless location is disabled.
    • The NSE links OneSignalExtension.
  • OneSignaliOSDependencies no longer writes the EDM iosPod XML. It deletes the previously generated file, so upgraded projects don't install the pods alongside the package.
  • Packages:
    • All three require Unity 6000.0 / 23f1, and the validator enforces it.
    • com.onesignal.unitysdk.ios no longer depends on Unity EDM. The validator requires EDM for Android only.
    • The iOS editor asmdef is auto-referenced so app editor scripts can use the helper.
  • Demo:
    • The widget links OneSignalFramework through the helper.
    • The pod XML files are removed.
    • run-ios.sh and clean.sh drop the CocoaPods steps.
    • Unity EDM still writes an empty Podfile and runs pod install, because the Android package pulls it in. So the scripts and E2E build the workspace when it exists.
  • CI: E2E drops its own pod install. The release PR workflow bumps OneSignalSwiftPackage.cs and checks that the OneSignal-XCFramework release exists.

Unity EDM 2.0's own <remoteSwiftPackage> support isn't used: it only links UnityFramework (not the app or NSE), and it can be turned off in EDM's settings.

Stack:

  1. This PR
  2. docs: [SDK-5858] Swift package setup and v5 to v6 migration guide (2/2) #921 docs

Testing

Unit testing

There's no Unity test harness for the editor scripts. I ran OneSignalSwiftPackage against a real exported pbxproj with the Unity 6 Xcode API outside Unity: running it twice keeps 1 reference and the same product links, and an older pinned version is re-pinned.

Manual testing

On Unity 6000.4.11f1 and Xcode, using examples/demo on this branch:

  • The export has 8 product links: 3 on the app, 3 on UnityFramework, 1 on the NSE and 1 on the widget. The only Podfile is EDM's empty one.
  • The workspace builds for the simulator, with the 10 OneSignal frameworks embedded once in the app.
  • On a temporary iOS 27.2 simulator, the app launched and the SDK created a user and push subscription.

The publishing tools package was removed locally because it needs a Hub sign-in; that change is not committed. dotnet csharpier check . and validate-unity-distribution.py pass.

Affected code checklist

  • Notifications
  • Outcomes
  • Sessions
  • In-App Messaging
  • REST API requests
  • Public API changes

Checklist

Overview

  • I have filled out all REQUIRED sections above
  • PR does one thing
  • Any Public API changes are explained in the PR details and conform to existing APIs

Testing

  • I have included test coverage for these changes, or explained why they are not needed
  • All automated tests pass, or I explained why that is not possible
  • I have personally tested this on my device, or explained why that is not possible

Final pass

  • Code is as readable as possible.
  • I have reviewed this PR myself, ensuring it meets each checklist item

🤖 Generated with Claude Code

…aPods

CocoaPods trunk is read-only from Dec 2, 2026. The iOS post-processor now links
the OneSignal-XCFramework Swift package through Unity 6's PBXProject APIs, and
the generated iOS dependencies file is removed. All packages require Unity 6,
and the iOS package no longer depends on External Dependency Manager.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fadi-george
fadi-george removed this pull request from stack #922 December 1, 2026 01:19
@fadi-george
fadi-george changed the base branch from main to fadi/sdk-5858-merge-main-v6 December 1, 2026 01:19
@fadi-george fadi-george changed the title feat: [SDK-5858] add OneSignal to iOS builds as a Swift package (1/2) feat: [SDK-5858] add OneSignal to iOS builds as a Swift package (2/3) Dec 1, 2026
@fadi-george
fadi-george added this pull request to stack #924 December 1, 2026 01:20
Base automatically changed from fadi/sdk-5858-merge-main-v6 to v6 December 1, 2026 01:21
@fadi-george fadi-george changed the title feat: [SDK-5858] add OneSignal to iOS builds as a Swift package (2/3) feat: [SDK-5858] add OneSignal to iOS builds as a Swift package (1/2) Dec 1, 2026

@abdulraqeeb33 abdulraqeeb33 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fresh Replace export looks right. Product names match OneSignal-XCFramework 5.8.1, and a second pass keeps one package reference. Two things need to change before this lands.

Append never links an existing NSE. AddNotificationServiceExtension returns at BuildPostProcessor.cs:201 when OneSignalNotificationServiceExtension is already in the project. AddProduct(..., "OneSignalExtension") is at line 231, after that return. The pod edit this replaces ran before the return, and this PR deletes the generated pod XML, so an Append from a v5 export keeps the extension and then links nothing. NotificationService.swift imports OneSignalExtension. A Replace creates the target, which is the path the manual test ran (BuildOptions.None). Move the AddProduct call above the return. The write at the bottom of OnPostprocessBuild saves it.

The demo widget has the same hole at examples/demo/Assets/App/Editor/iOS/BuildPostProcessor.cs:208 (the link is at line 242). That post-processor has to WriteToFile before returning. The sound and icon steps reload the project from disk.

iOS-only projects do not compile. OneSignal.iOS.Editor.asmdef:5 still references Unity.ExternalDependencyManager.Editor. Nothing in that assembly uses it, and the iOS package no longer depends on EDM. Core does not pull EDM in. Without the Android package, Unity drops OneSignal.iOS.Editor and the post-processor never runs. autoReferenced: true takes the default editor assembly with it. Delete that reference.

Not blocking: with location turned off, Append leaves a previously linked OneSignalLocation in place (BuildPostProcessor.cs:305). A Replace omits it. The README already says to delete the Xcode project when toggling the flag.

Nit: examples/demo/run-ios.sh:186 and examples/demo-no-location/run-ios.sh:117 expand xcodebuild $CONTAINER unquoted, so a project path with a space splits. e2e.yml already uses an array.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants